package librus.cheeseChaser.util
{
	import starling.display.Sprite;
	import starling.events.Event;
	
	public class Sprite extends starling.display.Sprite
	{
		public function Sprite()
		{
			super();
			
			addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		}
		
		private function onAddedToStage(event:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
			startup();
		}
		
		protected function startup():void
		{
		}
		
		protected function set isListeningToResize(value:Boolean):void
		{
			if (value && !hasEventListener(Event.RESIZE))
				stage.addEventListener(Event.RESIZE, onResizeHandler);
			
			if (!value && hasEventListener(Event.RESIZE))
				stage.removeEventListener(Event.RESIZE, onResizeHandler);						
		} 
		
		override public function dispose():void
		{
			super.dispose();
			stage.removeEventListener(Event.RESIZE, onResizeHandler);	
		}
				
		private function onResizeHandler(event:Event):void
		{
			onResize();
		}
		
		protected function onResize():void
		{
			
		}
	}
}